﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace CslaHispano.EncapsulatedInvoke.Domain.Entities
{
    public partial class OptionEdit
    {
        #region Data Portal

        protected override void Child_Create()
        {
            using (BypassPropertyChecks)
            {
                OptionId = Guid.NewGuid().ToString();
                Status = true;                
            }
            base.Child_Create();
        }

        private void Child_Fetch(IDataReader data)
        {
            using (BypassPropertyChecks)
            {
                OptionId = data.GetString(data.GetOrdinal("OptionId"));
                ModuleId= data.GetString(data.GetOrdinal("ModuleId"));
                Code = data.GetString(data.GetOrdinal("Code"));
                Description = data.GetString(data.GetOrdinal("Description"));
                Status = data.GetBoolean(data.GetOrdinal("Status"));
            }
        }

        private void Child_Insert(ModuleEdit module)
        {
            //using (BypassPropertyChecks)
            //{
            //    var dal = IoCFactory.Instance.CurrentContainer.Resolve<IModuleOptionRepository>();

            //    using (BypassPropertyChecks)
            //    {
            //        dal.Insert(OptionId, module.ModuleId, Code, Description, Status);
            //    }

            //    dal = null;
            //}
        }

        private void Child_Update(ModuleEdit module)
        {
            //using (BypassPropertyChecks)
            //{
            //    var dal = IoCFactory.Instance.CurrentContainer.Resolve<IModuleOptionRepository>();

            //    using (BypassPropertyChecks)
            //    {
            //        dal.Update(OptionId, module.ModuleId, Code, Description, Status);
            //    }
            //    dal = null;
            //}
        }

        private void Child_DeleteSelf(ModuleEdit module)
        {
            //using (BypassPropertyChecks)
            //{
            //    var dal = IoCFactory.Instance.CurrentContainer.Resolve<IModuleOptionRepository>();

            //    using (BypassPropertyChecks)
            //    {
            //        dal.Delete(OptionId);
            //    }
            //    dal = null;
            //}
        }

        #endregion
    }
}
